import React, { Component } from 'react';
import { PanDescConstant } from '../constants/constant_en';
import { select_result } from '../actions/search_action';
import { ActionConstant } from '../actions/search_action';
import { is } from 'immutable';
import {first_row_style, last_row_style, div_style } from '../styles/pan_style'
import { CusSelector } from "./CusInput";


export const last_update_items = ['anytime', 'past 24 hours', 'past week', 'past month', 'past year']
export const file_type_items = [
    'any format',
    'Adobe Acrobat PDF(.pdf)',
    'Adobe Postscript(.ps)',
    'Autodesk DWF(.dwf)',
    'Google Earth KML(.kml)',
    'Google Earth KMZ(.kmz)',
    'Microsoft Excel(.xls)',
    'Microsoft PowerPoint(.ppt)',
    'Microsoft Word(.doc)',
    'Rich Text Format(.rtf)',
    'Shockwave Flash(.swf)'
]

export default class ResultComponent extends Component {
    componentDidMount() {

    }

    shouldComponentUpdate(nextProps, nextState){
        return !(this.props === nextProps || is(this.props, nextProps)) ||
            !(this.state === nextState || is(this.state, nextState));

    }

    render() {

        const { data, dispatch } = this.props;

        const last_update = data.get('content').get('last_update');
        const file_type = data.get('content').get('file_type');

        const file_type_filed = (
            <CusSelector
                style={first_row_style}
                title={PanDescConstant.file_type}
                value={file_type.toString()}
                list={file_type_items}
                hash="filetype"
                callback={(key) => {
                    dispatch(select_result(ActionConstant.type_select_result_filetype, key))}
                }
            />
        )


        const last_update_filed = (
            <CusSelector
                style={last_row_style}
                title={PanDescConstant.last_update}
                value={last_update.toString()}
                list={last_update_items}
                hash="lastupdate"
                callback={(key) => {
                    dispatch(select_result(ActionConstant.type_select_result_last_update, key))}
                }
            />
        )



        return (
            <div style={div_style}>
                {file_type_filed}
                {last_update_filed}
            </div>
        );


    }
}

